package com.siyougame.business.util;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import com.siyougame.business.controller.admin.user.vo.WxUserCreateReqVO;
import com.siyougame.business.controller.app.vo.ThirdUserDTO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ThirdUserUtil {
    @Value("${third.userDetail}")
    private  String url;
    /**
     * 获取用户详情
     */
    public ThirdUserDTO getUserDetail(WxUserCreateReqVO createReqVO, String token) {
    HttpResponse response = HttpRequest.get(url)
                .header(Header.AUTHORIZATION, token)
                .header(Header.CONTENT_TYPE, "text/plain")
                .header(Header.ACCEPT, "*/*")
                .disableCookie() // 禁用自动携带 Cookie
                .body(JSONUtil.toJsonStr(createReqVO)) // GET 请求一般不带 body，建议去掉
                .execute();

        ThirdUserDTO thirdUserDTO = JSONUtil.toBean(response.body(), ThirdUserDTO.class);
        return thirdUserDTO;
    }

}
